package com.eascs.crm.nsEditDetail.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.eascs.crm.nsEditDetail.dao.NsEditDetailDao;
import com.eascs.crm.nsEditDetail.entity.CustomerAssetInfo;
import com.eascs.crm.nsEditDetail.entity.CustomerAssetInfoHis;

/**
* @author bao.pan 2017年7月12日 下午5:05:21
*/
@Service
public class CustomerAssetInfoService {
	@Autowired
	NsEditDetailDao nsDao;
	public CustomerAssetInfo queryById(String loanapplyno) {
		return nsDao.findEntity("SELECT * from customer_asset_info f where f.loanapply_no=?", CustomerAssetInfo.class, loanapplyno);
	}
	@Transactional(transactionManager="o2oTransactionManager",rollbackFor=Exception.class)
	public boolean update(CustomerAssetInfo info,CustomerAssetInfoHis his) {
		return nsDao.updateById(info) > 0&&nsDao.insert(his)>0;
	}
	@Transactional(transactionManager="o2oTransactionManager",rollbackFor=Exception.class)
	public boolean add(CustomerAssetInfo info,CustomerAssetInfoHis his){
		return nsDao.insert(info)>0&&nsDao.insert(his)>0;
	}
	public String findAssetByloanapplyno(String loanapplyno){
		CustomerAssetInfo c=queryById(loanapplyno);
		if (c!=null) {
			return "1";
		}
		return null;
	}
}
